<?php

namespace app\controllers;

use app\services\UserService;

/**
 * 用户中心
 */

class UserController extends BaseController
{
	public function __construct()
	{
		parent::__construct();

		(new UserService())->checkLogin();
	}
	
	public function index()
	{
		$data = [
			"title"	=> "用户中心",
		];
		return \View::display("user/index", $data);
	}
	
	public function register()
	{
		$data = [];
		return \View::display("user/register", $data);
	}
	
	public function login()
	{
		$data = [];
		return \View::display("user/login", $data);
	}
	
	public function logout()
	{
		return (new UserService())->logout();
	}
	
	/**
	 * /user/info/2
	 * @param $uid
	 * @return mixed
	 */
	public function info($uid = 0)
	{
		$uid = (int)$uid;
		$data = (new UserService())->userInfo($uid);
		return \View::display("user/info", $data);
	}
}
